<?php include "templates/include/header.php" ?>

      <div id="adminHeader">
        <h2>Administration des Saisons</h2>
        <p>Vous etes connect&eacute; en tant que <b><?php echo htmlspecialchars( $_SESSION['username']) ?></b>. <a href="admin.php?action=logout"?>Se D&eacute;connecter</a></p>
      </div>

      <h1><?php echo htmlspecialchars( $results['pageTitle'] )?></h1>

      <form action="admin.php?action=<?php echo $results['formAction']?>" method="post">
        <input type="hidden" name="seasonId" value="<?php echo $results['edit']->id ?>"/>

<?php if ( isset( $results['errorMessage'] ) ) { ?>
        <div class="errorMessage"><?php echo $results['errorMessage'] ?></div>
<?php } ?>

        <div>
          <label for="title">Saison de:</label>
          <input id="title" name="title" placeholder="aaaa-aaaa" maxlength="25" value="<?php if ( isset( $results['edit']->title ) ) echo( $results['edit']->title )?>"/>
        </div>
        <br/>
        <table width="90%" align="center" valign="middle">
          <?php
            if( isset( $results['event']['results'] ) ) {
              foreach( $results['event']['results'] as $event ) { ?>
                <tr onclick="location='admin.php?action=editEvent&amp;eventId=<?php echo( $event->id );?>'">
                  <td>
                    <?php
                      if ( isset( $event->title ) ) {
                        echo( htmlspecialchars( $event->title ) );
                      }
                    ?>
                  </td>
                </tr>
        <?php }
            } ?>
        </table>
        <br/>
        <div class="buttons">
          <input type="submit" name="saveChanges" value="Enregister" />
          <input type="submit" formnovalidate name="cancel" value="Annuler" />
        </div>
      </form>

<?php 
    if ( $results['edit']->id ) { ?>
      <p><a href="admin.php?action=newEvent&amp;seasonId=<?php echo $results['edit']->id ?>">Ajouter un Evenement</a></p>
      <p><a href="admin.php?action=deleteSeason&amp;seasonId=<?php echo $results['edit']->id ?>" onclick="return confirm('Supprimer cet element ?')">Supprimer cet Element</a></p>
<?php } ?>

<?php include "templates/include/footer.php" ?>
